package com.koron.plan.web.patrolplan.bean.convertor;

import com.koron.bean.plan.patrol.dto.PatrolDto;
import com.koron.bean.plan.patrol.po.PatrolEquipmentItemPo;
import com.koron.bean.plan.patrol.po.PatrolEquipmentParamsPo;
import com.koron.bean.plan.patrol.po.PatrolPo;
import com.koron.bean.plan.patrol.vo.PatrolEnvCheckVo;
import com.koron.bean.plan.patrol.vo.PatrolEquipmentVo;
import com.koron.bean.plan.patrol.vo.PatrolPointVo;
import com.koron.plan.web.patrolplan.bean.entity.PatrolPlanEnvBean;
import com.koron.plan.web.patrolplan.bean.entity.PatrolPlanEquipBean;
import com.koron.plan.web.patrolplan.bean.entity.PatrolPlanItemBean;
import com.koron.plan.web.patrolplan.bean.entity.PatrolPlanRecordBean;
import com.koron.plan.web.patrolplan.bean.vo.PatrolPlanEquipVO;
import com.koron.plan.web.patrolplan.bean.vo.PatrolPlanPointDetailVO;
import com.koron.plan.web.patrolplan.bean.vo.PatrolPlanVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

/**
 * @author twcao
 * @title: PatrolPlanPointConvertor
 * @projectName GDH_EAM_V2
 * @description: 巡视点实体转换
 * @date 2021/10/2814:09
 */
@Mapper(componentModel = "spring")
public interface PatrolPlanConvertor {

    PatrolPlanEquipBean equipVOToBean(PatrolPlanEquipVO vo);

    List<PatrolPlanEquipBean> equipVOsToBeans(List<PatrolPlanEquipVO> vos);

    @Mappings({
            @Mapping(source = "id", target = "planId"),
            @Mapping(source = "code", target = "planCode"),
            @Mapping(source = "planDeptId", target = "belongDeptId"),
            @Mapping(source = "planDeptName", target = "belongDeptName"),
            @Mapping(source = "patrolDeptId", target = "patrolDeptId"),
            @Mapping(source = "patrolDeptName", target = "patrolDeptName"),
            @Mapping(source = "staffingWay", target = "arrangement"),
            @Mapping(source = "locationId", target = "locationId"),
            @Mapping(source = "locationName", target = "locationName"),
            @Mapping(source = "mustSign", target = "mustSign"),
            @Mapping(source = "arriveWay", target = "arriveWay"),
            @Mapping(source = "patrolCategory", target = "patrolType"),
            @Mapping(source = "readyWork", target = "prepare"),
            @Mapping(source = "remark", target = "remarks"),
            @Mapping(source = "code", target = "code", ignore = true),
            @Mapping(source = "deleteFlag", target = "deleteFlag", ignore = true),
            @Mapping(source = "id", target = "id", ignore = true)
    })
    PatrolDto planBasicToOrder(PatrolPlanVO vo);

    @Mappings({
            @Mapping(source = "envs", target = "envCheckVos"),
            @Mapping(source = "equips", target = "equipmentVos"),
            @Mapping(source = "id", target = "planPatrolPointId"),
            @Mapping(source = "id", target = "id", ignore = true),
            @Mapping(source = "createTime", target = "createTime", ignore = true),
            @Mapping(source = "deleteFlag", target = "deleteFlag", ignore = true)
    })
    PatrolPointVo pointDetailToOrderPoint(PatrolPlanPointDetailVO detailVO);

    @Mappings({
            @Mapping(source = "envNorm", target = "name"),
            @Mapping(source = "sort", target = "sort"),
            @Mapping(source = "id", target = "id", ignore = true),
            @Mapping(source = "createTime", target = "createTime", ignore = true),
            @Mapping(source = "deleteFlag", target = "deleteFlag", ignore = true)
    })
    PatrolEnvCheckVo envToOrderEnv(PatrolPlanEnvBean env);

    List<PatrolEnvCheckVo> envsToOrderEnvs(List<PatrolPlanEnvBean> envs);

    @Mappings({
            @Mapping(source = "patrolPointId", target = "patrolPointId"),
            @Mapping(source = "equipmentId", target = "equipmentId"),
            @Mapping(source = "equipmentName", target = "name"),
            @Mapping(source = "items", target = "equipmentItemPos"),
            @Mapping(source = "records", target = "equipmentParamsPos"),
            @Mapping(source = "id", target = "id", ignore = true),
            @Mapping(source = "deleteFlag", target = "deleteFlag", ignore = true)
    })
    PatrolEquipmentVo equipToOrderEquip(PatrolPlanEquipVO vo);

    @Mappings({
            @Mapping(source = "patrolPointId", target = "patrolPointId"),
            @Mapping(source = "patrolEquipmentId", target = "patrolEquipmentId"),
            @Mapping(source = "itemName", target = "checkName"),
            @Mapping(source = "itemValue", target = "standardName"),
            @Mapping(source = "sort", target = "sort"),
            @Mapping(source = "createTime", target = "createTime", ignore = true),
            @Mapping(source = "id", target = "id", ignore = true),
            @Mapping(source = "deleteFlag", target = "deleteFlag", ignore = true),
            @Mapping(source = "runState", target = "runState")
    })
    PatrolEquipmentItemPo itemToOrderItem(PatrolPlanItemBean item);

    List<PatrolEquipmentItemPo> itemsToOrderItems(List<PatrolPlanItemBean> items);

    @Mappings({
            @Mapping(source = "patrolPointId", target = "patrolPointId"),
            @Mapping(source = "patrolEquipmentId", target = "patrolEquipmentId"),
            @Mapping(source = "itemName", target = "name"),
            @Mapping(source = "itemUnit", target = "unit"),
            @Mapping(source = "sort", target = "sort"),
            @Mapping(source = "deleteFlag", target = "deleteFlag", ignore = true),
            @Mapping(source = "runState", target = "runState")
    })
    PatrolEquipmentParamsPo recordToParam(PatrolPlanRecordBean record);

    List<PatrolEquipmentParamsPo> recordsToParams(List<PatrolPlanRecordBean> records);


    PatrolPo patrolDtoToPatrolVo(PatrolDto patrolDto);

}
